<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"    
    xmlns:s="http://jboss.com/products/seam/taglib">

  <ui:composition template="template.xhtml">
   
    <ui:define name="head">
      <link href="style/security.css" rel="stylesheet" type="text/css"/>
    </ui:define>   
   
    <ui:define name="content">
        
      <script type="text/javascript">
        function confirmDelete()
        {
          return confirm("Are you sure you wish to delete this role? This action cannot be undone.");
        }
      </script>

      <div id="contentMain">

  	    <h2>Role Manager</h2>  
  	    
        <s:button action="#{roleAction.createRole}" styleClass="newrole" rendered="#{s:hasPermission('seam.account', 'create', null)}"/>
  	    
        <h:dataTable 
            id="threads"
            value="#{roles}" 
            var="role" 
            styleClass="security"
            cellspacing="0"
            headerClass="header"
            rowClasses="odd,even"
            columnClasses=",,action">
          <h:column width="auto">
            <f:facet name="header">Role</f:facet>
            #{role}
          </h:column>
          <h:column width="auto">
            <f:facet name="header">Member Of</f:facet>
            #{roleSearch.getRoleGroups(role)}
          </h:column>
          <h:column width="auto">
            <f:facet name="header">Action</f:facet>          
            <s:fragment rendered="#{s:hasPermission('seam.role', 'update')}">
              <s:link value="Edit" action="#{roleAction.editRole(roleSearch.selectedRole)}"/><span> | </span>
            </s:fragment>
            <s:link value="Delete" action="#{identityManager.deleteRole(roleSearch.selectedRole)}"
                    rendered="#{s:hasPermission('seam.role', 'delete')}"
                    onclick="return confirmDelete()"/>              
          </h:column>
  	    </h:dataTable>
	    </div>
	    
    </ui:define>
    
  </ui:composition>
</html>
